package com.lujianing.service.impl;


import com.lujianing.dao.ArticleMapper;
import com.lujianing.model.Article;
import com.lujianing.model.ArticleExample;
import com.lujianing.page.Page;
import com.lujianing.page.PageHelper;
import com.lujianing.service.ArticleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by Administrator on 2014-05-22.
 */
@Service
public class ArticleServiceImpl implements ArticleService {

    @Autowired
    private ArticleMapper articleMapper;


    @Override
    public Page listPage(int pageNum, int pageSize) {
        //当第三个参数没有或者为true的时候，进行count查询
        PageHelper.startPage(pageNum, pageSize);
        //返回结果默认是List<SysLoginLog>
        //可以通过强制转换为Page<SysLoginLog>,该对象除了包含返回结果外，还包含了分页信息
        Page<Article> pages = (Page<Article>) articleMapper.selectByExample(new ArticleExample());
        //return newsMapper.selectByExample(new NewsExample());
        return pages;
    }

    @Override
    public List<Article> listAll() {
        return articleMapper.selectByExample(new ArticleExample());
    }
}
